<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap{

	#Métodos devem começar com _init para serem carregados automaticamente

	public function _initLoader(){
		Zend_Loader_Autoloader::getInstance()->registerNamespace("Application_");
	}

	#Registrando uma conexão com o banco de dados
	public function _initDb(){
		$config = $this->getOption('resources');
		$db = Zend_Db::Factory($config['db']['adapter'], $config['db']['params']);
		Zend_Db_Table_Abstract::setDefaultAdapter($db);
		Zend_Registry::set("db",$db);
		
	}
	
	public function _initLayout(){
		Zend_Layout::startMvc(array('layout'=>'layout','layoutPath'=>APPLICATION_PATH . "/layouts"));
	}
	
	public function _initViewHelpers(){
		$layout = Zend_Layout::getMvcInstance();
		$view = $layout->getView();
		$view->addHelperPath(APPLICATION_PATH . "/views/helpers","Application_View_Helper");
	}

	protected function _initNavigation(){
		$layout = Zend_Layout::getMvcInstance();
		$view = $layout->getView();
		$navigation = new Zend_Navigation($this->getOption("navigation"));
		$view->navigation($navigation);
	}

	/*
	public function _initPlugins(){
		Zend_Controller_Front::getInstance()->registerPlugin(new Application_Plugin_Exemplo());
	}
	*/
}
